.pragma library

function convertToStrokes(fullString) {
    // Convert numbers to strokes presentations for the query results of Stroke Order and Stroke 5 input methods.
    var r = fullString
    r = replaceAll(r, "1","一")
    r = replaceAll(r, "2","丨")
    r = replaceAll(r, "3","丿")
    r = replaceAll(r, "4","丶")
    r = replaceAll(r, "5","乛")
    return r
}

function convertToCangJie(fullString) {
    // Convert alphabet inputs to CangJii radicals for the query results of CangJie and Simplified CangJie input methods.
    var r = fullString.toUpperCase()
    r = replaceAll(r, "A","日")
    r = replaceAll(r, "B","月")
    r = replaceAll(r, "C","金")
    r = replaceAll(r, "D","木")
    r = replaceAll(r, "E","水")
    r = replaceAll(r, "F","火")
    r = replaceAll(r, "G","土")
    r = replaceAll(r, "H","竹")
    r = replaceAll(r, "I","戈")
    r = replaceAll(r, "J","十")
    r = replaceAll(r, "K","大")
    r = replaceAll(r, "L","中")
    r = replaceAll(r, "M","一")
    r = replaceAll(r, "N","弓")
    r = replaceAll(r, "O","人")
    r = replaceAll(r, "P","心")
    r = replaceAll(r, "Q","手")
    r = replaceAll(r, "R","口")
    r = replaceAll(r, "S","尸")
    r = replaceAll(r, "T","廿")
    r = replaceAll(r, "U","山")
    r = replaceAll(r, "V","女")
    r = replaceAll(r, "W","田")
    r = replaceAll(r, "X","難")
    r = replaceAll(r, "Y","卜")
    r = replaceAll(r, "Z","重")
    return r
}

function convertToZhuYin(fullString) {
    // Convert alphabet inputs to ZhuYin symbols for the query results of the ZhuYin input method.
    var r = fullString.toUpperCase()
    r = replaceAll(r, "A","ㄇ")
    r = replaceAll(r, "B","ㄖ")
    r = replaceAll(r, "C","ㄏ")
    r = replaceAll(r, "D","ㄎ")
    r = replaceAll(r, "E","ㄍ")
    r = replaceAll(r, "F","ㄑ")
    r = replaceAll(r, "G","ㄕ")
    r = replaceAll(r, "H","ㄘ")
    r = replaceAll(r, "I","ㄛ")
    r = replaceAll(r, "J","ㄨ")
    r = replaceAll(r, "K","ㄜ")
    r = replaceAll(r, "L","ㄠ")
    r = replaceAll(r, "M","ㄩ")
    r = replaceAll(r, "N","ㄙ")
    r = replaceAll(r, "O","ㄟ")
    r = replaceAll(r, "P","ㄣ")
    r = replaceAll(r, "Q","ㄆ")
    r = replaceAll(r, "R","ㄐ")
    r = replaceAll(r, "S","ㄋ")
    r = replaceAll(r, "T","ㄔ")
    r = replaceAll(r, "U","ㄧ")
    r = replaceAll(r, "V","ㄒ")
    r = replaceAll(r, "W","ㄊ")
    r = replaceAll(r, "X","ㄌ")
    r = replaceAll(r, "Y","ㄗ")
    r = replaceAll(r, "Z","ㄈ")
    r = replaceAll(r, "1","ㄅ")
    r = replaceAll(r, "2","ㄉ")
    r = replaceAll(r, "3","ˇ")
    r = replaceAll(r, "4","ˋ")
    r = replaceAll(r, "5","ㄓ")
    r = replaceAll(r, "6","ˊ")
    r = replaceAll(r, "7","˙")
    r = replaceAll(r, "8","ㄚ")
    r = replaceAll(r, "9","ㄞ")
    r = replaceAll(r, "0","ㄢ")
    r = replaceAll(r, "-","ㄦ")
    r = replaceAll(r, ";","ㄤ")
    r = replaceAll(r, ",","ㄝ")
    r = replaceAll(r, ".","ㄡ")
    r = replaceAll(r, "/","ㄥ")
    return r
}

function convertToDaiYi3(fullString) {
    // Convert alphabet inputs to DaYi 3rd Edition radicals for the query results of the DaYi 3rd Edition input method.
    var r = fullString.toUpperCase()
    r = replaceAll(r, "A","人")
    r = replaceAll(r, "B","馬")
    r = replaceAll(r, "C","七")
    r = replaceAll(r, "D","日")
    r = replaceAll(r, "E","一")
    r = replaceAll(r, "F","土")
    r = replaceAll(r, "G","手")
    r = replaceAll(r, "H","鳥")
    r = replaceAll(r, "I","木")
    r = replaceAll(r, "J","月")
    r = replaceAll(r, "K","立")
    r = replaceAll(r, "L","女")
    r = replaceAll(r, "M","雨")
    r = replaceAll(r, "N","魚")
    r = replaceAll(r, "O","口")
    r = replaceAll(r, "P","耳")
    r = replaceAll(r, "Q","石")
    r = replaceAll(r, "R","工")
    r = replaceAll(r, "S","革")
    r = replaceAll(r, "T","糸")
    r = replaceAll(r, "U","艸")
    r = replaceAll(r, "V","禾")
    r = replaceAll(r, "W","山")
    r = replaceAll(r, "X","水")
    r = replaceAll(r, "Y","火")
    r = replaceAll(r, "Z","心")
    r = replaceAll(r, ",","力")
    r = replaceAll(r, ".","點")
    r = replaceAll(r, "/","竹")
    r = replaceAll(r, "0","金")
    r = replaceAll(r, "1","言")
    r = replaceAll(r, "2","牛")
    r = replaceAll(r, "3","目")
    r = replaceAll(r, "4","四")
    r = replaceAll(r, "5","王")
    r = replaceAll(r, "6","門")
    r = replaceAll(r, "7","田")
    r = replaceAll(r, "8","米")
    r = replaceAll(r, "9","足")
    r = replaceAll(r, ";","虫")
    return r
}

function convertToWuBi(fullString) {
    // Convert alphabet inputs to WuBi symbols for the query results of the WuBi input method.
    var r = fullString.toUpperCase()
    r = replaceAll(r, "A","工");
    r = replaceAll(r, "B","子");
    r = replaceAll(r, "C","又");
    r = replaceAll(r, "D","大");
    r = replaceAll(r, "E","月");
    r = replaceAll(r, "F","土");
    r = replaceAll(r, "G","王");
    r = replaceAll(r, "H","目");
    r = replaceAll(r, "I","水");
    r = replaceAll(r, "J","日");
    r = replaceAll(r, "K","口");
    r = replaceAll(r, "L","田");
    r = replaceAll(r, "M","山");
    r = replaceAll(r, "N","已");
    r = replaceAll(r, "O","火");
    r = replaceAll(r, "P","之");
    r = replaceAll(r, "Q","金");
    r = replaceAll(r, "R","白");
    r = replaceAll(r, "S","木");
    r = replaceAll(r, "T","禾");
    r = replaceAll(r, "U","立");
    r = replaceAll(r, "V","女");
    r = replaceAll(r, "W","人");
    r = replaceAll(r, "X","纟");
    r = replaceAll(r, "Y","言");
    return r
}


function convertToArray30(fullString) {
    // Convert alphabet inputs to Array 30 keys edition symbols for the query results of the Array 30 keys edition input method.
    var r = fullString.toUpperCase()
    r = replaceAll(r, ",","8v");
    r = replaceAll(r, ".","9v");
    r = replaceAll(r, "/","0v");
    r = replaceAll(r, ";","0-");
    r = replaceAll(r, ";","0-");
    r = replaceAll(r, "A","1-");
    r = replaceAll(r, "B","5v");
    r = replaceAll(r, "C","3v");
    r = replaceAll(r, "D","3-");
    r = replaceAll(r, "E","3^");
    r = replaceAll(r, "F","4-");
    r = replaceAll(r, "G","5-");
    r = replaceAll(r, "H","6-");
    r = replaceAll(r, "I","8^");
    r = replaceAll(r, "J","7-");
    r = replaceAll(r, "K","8-");
    r = replaceAll(r, "L","9-");
    r = replaceAll(r, "M","7v");
    r = replaceAll(r, "N","6v");
    r = replaceAll(r, "O","9^");
    r = replaceAll(r, "P","0^");
    r = replaceAll(r, "Q","1^");
    r = replaceAll(r, "R","4^");
    r = replaceAll(r, "S","2-");
    r = replaceAll(r, "T","5^");
    r = replaceAll(r, "U","7^");
    r = replaceAll(r, "V","4v");
    r = replaceAll(r, "W","2^");
    r = replaceAll(r, "X","2v");
    r = replaceAll(r, "Y","6^");
    r = replaceAll(r, "Z","1v");
    return r
}

function replaceAll(fullString, stringToFind,stringToReplace){
    // Replace all instances of a substring with another substring within a string.
    var temp = fullString
    var index = fullString.indexOf(stringToFind);
    while(index != -1){
        temp = temp.replace(stringToFind,stringToReplace);
        index = temp.indexOf(stringToFind);
    }
    return temp;

}
